<template>
  <Modal v-model="modal" :title="title">
    <div class="tag-modal">
      <div class="content">
        <TabPane label name="tab1" class="ht400 scroll">
          <Table
            stripe
            border
            :columns="list.columns"
            :data="list.data"
            no-data-text="亲，没有找到相关记录哦！~"
          ></Table>
          <Loader :status="list.status" @refresh="getData"></Loader>
        </TabPane>
      </div>
    </div>
    <div slot="footer">
      <Button @click="modal = false" size="large" type="text">取消</Button>
    </div>
  </Modal>
</template>

<script>
export default {
  data() {
    return {
      modal: false,
      loading: false,
      title: '',
      list: {
        currentPage: 1,
        pageSize: window.$pageSize,
        totalItem: 0,
        columns: [
          {
            title: '轮胎规格名称',
            key: 'productName',
            align: 'left'
          },
          {
            title: '条数',
            key: 'quantity',
            align: 'left',
            render: (h, params) => {
              return h('div', params.row.quantity + '条')
            }
          },
          {
            title: '单价(元/条)',
            key: 'productPrice',
            align: 'left',
            render: (h, params) => {
              return h('div', params.row.productPrice)
            }
          }
        ],
        data: [],
        loading: false,
        status: 'pass'
      }
    }
  },
  methods: {
    open(item) {
      this.modal = true
      this.list.status = 'loading'
      if (item.type == 'order') {
        this.title = '单号: ' + item.row.orderNo + '的详细记录'
        let params = {
          orderId: item.row.orderId
        }
        this.$ajaxGet('/report/store_rebate_year_report/order_detail', params).then(data => {
          this.list.data = []
          this.list.data = data || []
          this.list.status = 'pass'
        })
      } else {
        this.title = '单号: ' + item.row.afterSaleNo + '的详细记录'
        let params = {
          afterSaleId: item.row.afterSaleId
        }
        this.$ajaxGet('/report/store_rebate_year_report/order_refund_detail', params).then(data => {
          this.list.data = []
          this.list.data = data || []
          this.list.status = 'pass'
        })
      }
    },
    close() {
      this.modal = false
    }
  }
}
</script>